package com.shanghaionstar.nav;

import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.Window;

import com.onstar.cn.framework.annotation.ContentView;
import com.onstar.cn.framework.annotation.OnClick;
import com.onstar.cn.framework.mvp.base.core.BaseActivity;
import com.onstar.cn.framework.mvp.base.core.BasePresenter;
import com.onstar.cn.vehicle.result.PollingResult;
import com.shanghaionstar.R;

/**
 * Created by 6335yz on 2016/7/15.
 */
@ContentView(R.layout.nav_vehicle_alert_dialog)
public class NavDialogActivity extends BaseActivity implements View.OnClickListener {

    private PollingResult pollingResult;

    @Override
    public BasePresenter getPresenter() {
        return null;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
//        setTheme(android.R.style.Theme_Dialog);
        setTheme(R.style.nav_vehicle_alert_dialog);
        super.onCreate(savedInstanceState);
        if (getIntent().getSerializableExtra("pollingResult") != null) {
            pollingResult = (PollingResult) getIntent().getSerializableExtra("pollingResult");
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        Window window = getWindow();
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        window.setLayout((int) (dm.widthPixels * 0.97), (int) (dm.heightPixels * 0.35));//Here!
        window.setGravity(Gravity.CENTER);
    }

    @OnClick({R.id.dialog_cancel, R.id.dialog_confirm})
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.dialog_cancel:
                finish();
                break;
            case R.id.dialog_confirm:
                Intent intent = new Intent(this, NavActivity.class);
                intent.putExtra("isShowToMap", true);
                intent.putExtra("pollingResult", pollingResult);
                startActivity(intent);
                break;
        }
    }
}
